<template>
	<view class="column-css">
		<view class="column-css" style="margin-top: 200rpx; align-items: center;text-align: center;">
			<image style="width: 165rpx;height: 165rpx;border-radius: 50%;overflow:hidden;" src="../../static/icon_ecco.png"></image>
			
			<view v-if="iscar && num == 1">
				<view style="font-size: 36rpx;margin-top: 30rpx;">{{text}}资料已提交平台审核</view>
				<view style="font-size: 30rpx;margin-top: 30rpx;">申诉过程中{{text}}可以正常接单</view>
			</view>
			<view v-else style="font-size: 36rpx;margin-top: 30rpx;">资料已提交审核</view>
		</view>
		<view v-if="isw == 1" style="margin-top: 20rpx;text-align: center;">请等待所属企业通过审核后使用</view>
		<view v-if="isw == 1" style="margin-top: 20rpx;text-align: center;">审核企业：{{etpName}}</view>
		<view v-if="iscar == false" class="view-button">前往开通平安银行互联网账户</view>
		<view v-if="iscar == false" style="margin-top: 20rpx;text-align: center;" @click="onback()">返回首页</view>
		<view v-if="iscar" class="view-button" @click="onbackcar()">返回</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			iscar: true,
			num: '',
			text: '',
			isw: 0,
			etpName: uni.getStorageSync(this.DATA_KEY.etpName)
		};
	},
	methods: {
		onMyinfo() {
			let driverId = uni.getStorageSync(this.DATA_KEY.userInfo).driverId;
			this.wxRequest({
				url: `${this.API}/driverService/getDriverInfoByDriverID?driver_id=` + driverId + '&etp_id=' + uni.getStorageSync(this.DATA_KEY.etpId),
				method: 'POST',
				title: '加载中...',
				success: res => {
					console.log(res)
					this.user = res.data.data.userModel;
					uni.setStorageSync(this.DATA_KEY.userInfo, res.data.data.userModel);
					this.islivingcertifi = this.user.livingBodyState == 0 ? '未认证' : '已认证';
				},
			});
		},
		saveFaceVerify() {
			this.wxRequest({
				url: `${this.API}/driverService/saveFaceVerifyState`,
				method: 'POST',
				data: {
					driverId: uni.getStorageSync(this.DATA_KEY.userInfo).driverId,
					orderNumber: uni.getStorageSync(this.DATA_KEY.orderNumber),
					platformCoId: uni.getStorageSync(this.DATA_KEY.platformCoNo) == '0001' ? '100001' : '100002',
					accessToken: uni.getStorageSync(this.DATA_KEY.accessToken)
				},
				success: res => {
					console.log(res)
					this.onMyinfo()
					uni.removeStorageSync(this.DATA_KEY.accessToken);
					uni.removeStorageSync(this.DATA_KEY.orderNumber);
					uni.removeStorageSync(this.DATA_KEY.liveFlag);
				},
				fail: err => {
					uni.removeStorageSync(this.DATA_KEY.accessToken);
					uni.removeStorageSync(this.DATA_KEY.orderNumber);
					uni.removeStorageSync(this.DATA_KEY.liveFlag);
				},
				complete: () => {
					uni.removeStorageSync(this.DATA_KEY.accessToken);
					uni.removeStorageSync(this.DATA_KEY.orderNumber);
					uni.removeStorageSync(this.DATA_KEY.liveFlag);
				}
			});
		},
		
		onback() {
			if (uni.getStorageSync(this.DATA_KEY.userInfo).phoneNumber) {
				this.wxRequest({
					url: `${this.API}/user/myInfo`,
					method: 'POST',
					data: {
						phoneNumber: uni.getStorageSync(this.DATA_KEY.userInfo).phoneNumber
					},
					success: res => {
						const userInfo = uni.getStorageSync(this.DATA_KEY.userInfo);
						userInfo.state = res.data.data.state;
						userInfo.lbsauthState = res.data.data.lbsauthState;
						uni.setStorageSync(this.DATA_KEY.userInfo, userInfo);
						uni.switchTab({
							url: '/pages/index/mine'
						});
					}
				});
			}
		},
		onbackcar() {
			// if (this.isw == 1) {
				uni.navigateBack({
					delta: 1
				});
			// } else {
			// 	uni.navigateBack({
			// 		delta: 2
			// 	});
			// }
		}
	},
	onShow() {
		console.log(uni.getStorageSync(this.DATA_KEY.liveFlag),333)
		if(uni.getStorageSync(this.DATA_KEY.liveFlag)){
			this.saveFaceVerify()
			this.onMyinfo()
		}
	},
	beforeDestroy() {
		if(uni.getStorageSync(this.DATA_KEY.liveFlag)){
			uni.setStorageSync(that.DATA_KEY.liveFlag, false);
		}
	},
	onLoad: function(options) {
		console.log('dddd', options.iscar);
		this.iscar = options.iscar;
		if(options.num){
			this.num = options.num
		}
		if(options.text){
			this.text = options.text
		}
		this.isw = options.isw ? options.isw : 0;
		console.log('dddd11', this.iscar);
		console.log('dddd11', this.isw);
		if (this.isw == 1 || this.isw == 2) {
			uni.setNavigationBarTitle({
				title: '委托收款人钱包（审核中)' //这是修改后的导航栏文字
			});
		}
	}
	// onUnload() {
	// 	this.onback();
	// }
};
</script>

<style>
page {
	background: #ffffff;
}
.row-css {
	display: flex;
	flex-direction: row;
}

.column-css {
	display: flex;
	flex-direction: column;
}

.view-button {
	display: flex;
	flex: 1;
	background: #2b7cff;
	border-radius: 15rpx;
	padding: 20rpx;
	margin: 0 30rpx;
	margin-top: 50rpx;
	justify-content: center;
	color: #ffffff;
}
</style>
